<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>教学实验环境实例管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		function vmChoose(selete)
		{
//			var option=selete.options[selete.selectedIndex].value;
//			window.location.href=option;
			var vmId=selete.options[selete.selectedIndex].value;
			$.ajax({
				type: "POST",
				url: "${ctx}/scene/sceneEnvironmentInstance/getVmUrl",
				data: {
					vmId:vmId
				},
				success: function (consoleUrl) {
					if(consoleUrl!=null&&consoleUrl!="")
						window.location.href=consoleUrl;
				},
				error:function(){

				}
			});

		}
		function viewDetail(id){
			console.info(id);
			$.ajax({
				type: "POST",
				url: "${ctx}/scene/sceneEnvironmentInstance/console",
				data: {
					ids:id
				},
				success: function (url) {
//					alertx(url);
					window.location.href=url;
				},
				error:function(){
					alert("error");
				}
			});
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/scene/sceneEnvironmentInstance/">教学实验环境实例列表</a></li>
		<%--<shiro:hasPermission name="scene:sceneEnvironmentInstance:edit"><li><a href="${ctx}/scene/sceneEnvironmentInstance/form">教学实验环境实例添加</a></li></shiro:hasPermission>--%>
	</ul>
	<%--<form:form id="searchForm" modelAttribute="sceneEnvironmentInstance" action="${ctx}/scene/sceneEnvironmentInstance/" method="post" class="breadcrumb form-search">--%>
		<%--<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>--%>
		<%--<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>--%>
		<%--<ul class="ul-form">--%>
			<%--<li><label>教学实验环境id：</label>--%>
				<%--<form:input path="id" htmlEscape="false" maxlength="64" class="input-medium"/>--%>
			<%--</li>--%>
			<%--<li><label>教学实验环境id：</label>--%>
				<%--<form:input path="environmentId" htmlEscape="false" maxlength="64" class="input-medium"/>--%>
			<%--</li>--%>
			<%--<li><label>创建时间：</label>--%>
				<%--<input name="beginEndDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"--%>
					<%--value="<fmt:formatDate value="${sceneEnvironmentInstance.beginEndDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"--%>
					<%--onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/> - --%>
				<%--<input name="endEndDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"--%>
					<%--value="<fmt:formatDate value="${sceneEnvironmentInstance.endEndDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"--%>
					<%--onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>--%>
			<%--</li>--%>
			<%--<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>--%>
			<%--<li class="clearfix"></li>--%>
		<%--</ul>--%>
	<%--</form:form>--%>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>教学实验环境</th>
				<th>实验时间</th>
				<th>实例创建时间</th>
				<th>实例创建用户</th>
				<shiro:hasPermission name="scene:sceneEnvironmentInstance:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="sceneEnvironmentInstance">
			<tr>
				<td>
					${sceneEnvironmentInstance.environmentName}
				</td>
				<td>
						${sceneEnvironmentInstance.environmentTime}小时
				</td>
				<td>
					<fmt:formatDate value="${sceneEnvironmentInstance.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
						${sceneEnvironmentInstance.createUserName}
				</td>

				<shiro:hasPermission name="scene:sceneEnvironmentInstance:edit"><td>
					<c:if test="${sceneEnvironmentInstance.instanceOsList!=null}">
						<%--<a href="javascript:viewDetail('${sceneEnvironmentInstance.id}')" title="查看">查看</a>--%>

						<select id="operateMachineSelect" name="operateMachineSelect" class="input-large" onchange="vmChoose(this)">
							<option value="">===控制台选择===</option>
							<c:forEach items="${sceneEnvironmentInstance.instanceOsList}" var="vm">
								<option value="${vm.vmTemplateId}">${vm.vmName}</option>
							</c:forEach>

						</select>
					</c:if>

					<a href="${ctx}/scene/sceneEnvironmentInstance/delete?id=${sceneEnvironmentInstance.id}" onclick="return confirmx('确认要删除该实例吗？', this.href)">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>